﻿using HTB.DevFx.Config;
[assembly: ConfigResource("res://Maple.Weixin.MP.Config.htb.devfx.weixin.mp.config", Index = 0)]

namespace Maple.Weixin.MP.Config
{
    public class WeixinServiceSetting : ConfigSettingElement, IWeixinServiceSetting
    {
        protected override void OnConfigSettingChanged()
        {
            base.OnConfigSettingChanged();
            this.AppId = this.GetRequiredSetting("appid");
            this.AppSecret = this.GetRequiredSetting("appsecret");
            this.Token = this.GetRequiredSetting("token");
            this.EncodingAESKey = this.GetRequiredSetting("encodingAESkey");
            this.RequestSetting = this.GetSetting<RequestSetting>("request");
        }

        #region Implementation of IWeixinServiceSetting

        public string AppId { get; private set; }  // AppId
        public string AppSecret { get; private set; }  // AppSecret
        public string Token { get; private set; }  // Token
        public string EncodingAESKey { get; private set; }
        public IRequestSetting RequestSetting { get; private set; }

        #endregion
    }

    internal class RequestSetting : ConfigSettingElement, IRequestSetting
    {
        protected override void OnConfigSettingChanged()
        {
            base.OnConfigSettingChanged();
            this.Monitor = this.GetSetting("monitor", false);
            this.Statistics = this.GetSetting("statistics", false);
        }

        #region Implementation of IRequestSetting

        public bool Monitor { get; private set; }
        public bool Statistics { get; private set; }

        #endregion
    }
}
